<template>
  <div class="container" id="container" ref="container">
    <div style="width: 210mm;">
      <h2 style="text-align: center;">{{seller.name}}交班报表</h2>
      <div><span style="width:50%">当班时间：{{startTime+"~"+endTime}}</span> <span>当班人：{{username}}</span></div>
      <div><span>班次：{{shiftoverType?shiftoverType.filter(item=>item.id == handType)[0].label : ''}}</span></div>
      <div><span>打印时间：{{now()}}</span> 打印人： {{user.username}}</div>
      <table border="1" cellspacing="0" cellpadding="0" style="float: left;width: 33%;">
        <tr>
          <th>账目信息</th>
        </tr>
        <tr>
          <td>房费金额：{{dataMap['房费']?dataMap['房费']:0}}</td>
        </tr>
        <tr>
          <td>消费金额：{{dataMap['消费']?dataMap['消费']:0}}</td>
        </tr>
        <tr>
          <td>POS商品：{{dataMap['消费点']?dataMap['消费点']:0}}</td>
        </tr>
        <tr>
          <td>非住客账：{{dataMap['非住客账']?dataMap['非住客账']:0}}</td>
        </tr>
        <tr>
          <td>红冲金额：-{{dataMap['红冲']?dataMap['红冲']:0}}</td>
        </tr>
        <tr>
          <td>会员充值：0</td>
        </tr>
        <tr>
          <td>商品退货：0</td>
        </tr>
        <tr>
          <td>应收合计：{{dataMap?dataMap['和']:0}}</td>
        </tr>
        <th>
          商品销售分析
        </th>
        <tr>
          <td>房间商品：{{dataMap['消费']?dataMap['消费']:0}}</td>

        </tr>
        <tr>
          <td>POS商品：{{dataMap['消费点']?dataMap['消费点']:0}}</td>

        </tr>
        <tr>
          <td>商品销售合计：{{(dataMap['消费']==null?0:dataMap['消费']) + (dataMap['消费点']==null?0:dataMap['消费点'])}}</td>

        </tr>
        <tr v-if="goodsPrint ">
          <td>
            <table border="1" cellspacing="0" cellpadding="0" style="width:100%">
              <tr>
                <th colspan="4">商品报表</th>
              </tr>
              <tr>
                <td>名字</td>
                <td>已结</td>
                <td>未结</td>
                <td>合计</td>
              </tr>
              <tr v-for="item in goods" :key="item.name">
                <td>{{item.name}}</td>
                <td>{{item.closed}}</td>
                <td>{{item.open}}</td>
                <td>{{item.closed+item.open}}</td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
      <table border="1" cellspacing="0" cellpadding="0" style="float: left;width: 33%;">
        <tr>
          <th>交班转交押金</th>
        </tr>
        <tr>
          <td>上班转交押金：{{nextDeposit}}</td>
        </tr>
        <tr v-for="(item,key) in upperDepositMap" :key="key" v-if="isFirst==1">
          <td v-if="key!='和'">{{key+"："+item}}</td>
        </tr>
        <tr>
          <th>本班实收押金</th>
        </tr>
        <tr v-for="(item,key) in depositMap" :key="key">
          <td v-if="key!='和'">{{key+"："+item}}</td>
        </tr>
        <tr>
          <td>合计：{{depositMap['和']}}</td>
        </tr>
        <tr>
          <th>应转下班押金：</th>
        </tr>
        <tr v-for="(item,key) in nextDepositMap" :key="key" v-if="isFirst==1">
          <td v-if="key!='和'">{{key+"："+item}}</td>
        </tr>
        <tr v-for="(item,key) in depositMap" :key="key" v-if="isFirst==0">
          <td v-if="key!='和'">{{key+"："+item}}</td>
        </tr>
        <tr>
          <td v-if="isFirst==1">应收合计：{{nextDepositMap['和']?nextDepositMap['和']:0}}</td>
          <td v-if="isFirst==0">应收合计：{{depositMap['和']?depositMap['和']:0}}</td>
        </tr>
      </table>
      <table border="1" cellspacing="0" cellpadding="0" style="float: left;width: 33%;">
        <tr>
          <th>交班转交营业款</th>
        </tr>
        <tr>
          <td>上班转交押金：{{nextDeposit}}</td>
        </tr>
        <tr v-for="(item,key) in upperMoneyMap" :key="key" v-if="isFirst==1">
          <td v-if="key!='和'">{{key+"："+item}}</td>
        </tr>
        <tr>

          <th>本班实收营业款</th>
        </tr>
        <tr v-for="(item,key) in payDataMap" :key="key">
          <td v-if="key!='和'">{{key+"："+item}}</td>
        </tr>
        <tr>
          <td>合计：{{payDataMap['和']}}</td>
        </tr>
        <tr>
          <th>应转下班营业款：</th>
        </tr>
        <tr v-for="(item,key) in nextMoneyMap" :key="key" v-if="isFirst==1">
          <td v-if="key!='和'">{{key+"："+item}}</td>
        </tr>
        <tr v-for="(item,key) in payDataMap" :key="key" v-if="isFirst==0">
          <td v-if="key!='和'">{{key+"："+item}}</td>
        </tr>
        <tr v-if="isFirst==1">
          <td>应收合计：{{nextMoneyMap['和']}}</td>
        </tr>
        <tr v-if="isFirst==0">
          <td>应收合计：{{payDataMap['和']}}</td>
        </tr>
      </table>

    </div>
  </div>
</template>
<script>
  import Moment from 'moment'
  export default {
    props: ['dataMap', 'handType', 'shiftoverType', 'nextDeposit', 'nextMoney', 'upperDepositMap', 'depositMap',
      'nextDepositMap', 'upperMoneyMap', 'payDataMap', 'nextMoneyMap',
      'startTime', 'endTime', 'user', 'seller', 'isFirst', 'username', 'goodsPrint', 'goods'
    ],
    data() {
      return {
        // dataMap:{},
        // nextDeposit:0,
        // nextMoney:0,
        // upperDepositMap:{},
        // depositMap:{},
        // nextDepositMap:{},
        // upperMoneyMap:{},
        // payDataMap:{},
        // nextMoneyMap:{}

      }
    },
    created() {

    },
    methods: {
      init() {
        // this.dataMap={},
        // this.nextDeposit=0,
        // this.nextMoney=0,
        // this.upperDepositMap={},
        // this.depositMap={},
        // this.nextDepositMap={},
        // this.upperMoneyMap={},
        // this.payDataMap={},
        // this.nextMoneyMap={}
      },
      setData(dataMap, nextDeposit, nextMoney, upperDepositMap, depositMap, nextDepositMap, upperMoneyMap, payDataMap,
        nextMoneyMap) {
        // this.init()

        //   for(let key in dataMap){
        // 	  this.$set(this.dataMap,key,dataMap[key])
        //   }
        //   this.nextDeposit=nextDeposit
        //   this.nextMoney=nextMoney
        // 	for(let key in upperDepositMap){
        // 		this.$set(this.upperDepositMap,key,upperDepositMap[key])
        // 	}
        // 	for(let key in depositMap){
        // 		this.$set(this.depositMap,key,depositMap[key])
        // 	}
        // 	for(let key in nextDepositMap){
        // 		this.$set(this.nextDepositMap,key,nextDepositMap[key])
        // 	}
        // 	for(let key in upperMoneyMap){
        // 		this.$set(this.upperMoneyMap,key,upperMoneyMap[key])
        // 	}
        // 	for(let key in payDataMap){
        // 		this.$set(this.payDataMap,key,payDataMap[key])
        // 	}
        // 	for(let key in nextMoneyMap){
        // 		this.$set(this.nextMoneyMap,key,nextMoneyMap[key])
        // 	}

        //   this.$forceUpdate();


      },
      getUser() {

        this.$http({
          url: this.$http.adornUrl('/hotel/thotelprinttemplate/printInfo'),
          method: 'get',
        }).then(({
          data
        }) => {
          if (data && data.code === 0) {
            console.log(data)
            this.user = data.user
            this.seller = data.seller
          } else {

          }
        })
      },
      now() {
        return Moment().locale('zh-cn').format('YYYY-MM-DD HH:mm:ss');
      }
    },
    mounted() {

    }

  }
</script>
